package Practice.Practice_02.UserManagementSystem;

import java.util.Scanner;

public class UpdateUser {
    public static void update(Person[] person){
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入要修改用户的ID号码");
        int index = sc.nextInt();
        for (int i = 0; i < person.length; i++) {
            if(index == i){
                System.out.println(person[i].getId() + " " + person[i].getName() + " "
                        + person[i].getPass() + " " + person[i].getEmail() + " " + person[i].getPower());
                System.out.println("=========================");
                break;
            }
        }
        System.out.println("请输入要更改的姓名");
        person[index].setName(sc.next());
        System.out.println("请输入要更改的密码");
        person[index].setPass(sc.next());
        System.out.println("请输入要更改的邮箱");
        person[index].setEmail(sc.next());
        System.out.println("请输入要更改的权限");
        person[index].setPower(sc.next());
        System.out.println("更改成功");
    }

    public static void update(Person[] person, int index){
        Scanner sc = new Scanner(System.in);
        System.out.println("您现在的信息是：");
        System.out.println(person[index].getId() + " " + person[index].getName() + " "
                + person[index].getPass() + " " + person[index].getEmail() + " " + person[index].getPower());
        System.out.println("=========================");
        System.out.println("请输入要修改的姓名");
        person[index].setName(sc.next());
        System.out.println("请输入要修改的密码");
        person[index].setPass(sc.next());
        System.out.println("请输入要修改的邮箱");
        person[index].setEmail(sc.next());
        System.out.println("修改成功");
    }
}
